using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace WindowsApplication1
{
	/// <summary>
	/// Summary description for reg.
	/// </summary>
	public class REGISTRATIONFORM : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txtsid;
		private System.Windows.Forms.TextBox txtcid;
		private System.Windows.Forms.TextBox txtname;
		private System.Windows.Forms.TextBox txtdob;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.GroupBox gpsex;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.TextBox txtfather;
		private System.Windows.Forms.RadioButton radfemale;
		private System.Windows.Forms.RadioButton radmale;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.GroupBox gppersonal;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.TextBox txtqualification;
		private System.Windows.Forms.TextBox txtemail;
		private System.Windows.Forms.TextBox txtaddress;
		private System.Windows.Forms.TextBox txtphone;
		private System.Windows.Forms.Button btnsubmit;
		private System.Windows.Forms.GroupBox gpstudentdetails;
		private System.Windows.Forms.Label lblcoursename;
		private System.Windows.Forms.Button btncancel;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox txtdoj;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		/// 

		
		private System.ComponentModel.Container components = null;

		public REGISTRATIONFORM()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.txtsid = new System.Windows.Forms.TextBox();
			this.txtcid = new System.Windows.Forms.TextBox();
			this.txtname = new System.Windows.Forms.TextBox();
			this.txtdob = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.gpsex = new System.Windows.Forms.GroupBox();
			this.radfemale = new System.Windows.Forms.RadioButton();
			this.radmale = new System.Windows.Forms.RadioButton();
			this.label5 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.txtfather = new System.Windows.Forms.TextBox();
			this.gppersonal = new System.Windows.Forms.GroupBox();
			this.txtphone = new System.Windows.Forms.TextBox();
			this.txtaddress = new System.Windows.Forms.TextBox();
			this.txtemail = new System.Windows.Forms.TextBox();
			this.txtqualification = new System.Windows.Forms.TextBox();
			this.label10 = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.btnsubmit = new System.Windows.Forms.Button();
			this.gpstudentdetails = new System.Windows.Forms.GroupBox();
			this.label13 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.txtdoj = new System.Windows.Forms.TextBox();
			this.label11 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.lblcoursename = new System.Windows.Forms.Label();
			this.btncancel = new System.Windows.Forms.Button();
			this.gpsex.SuspendLayout();
			this.gppersonal.SuspendLayout();
			this.gpstudentdetails.SuspendLayout();
			this.SuspendLayout();
			// 
			// txtsid
			// 
			this.txtsid.Location = new System.Drawing.Point(164, 32);
			this.txtsid.Name = "txtsid";
			this.txtsid.TabIndex = 0;
			this.txtsid.Text = "";
			this.txtsid.TextChanged += new System.EventHandler(this.txtsid_TextChanged);
			// 
			// txtcid
			// 
			this.txtcid.Location = new System.Drawing.Point(150, 120);
			this.txtcid.Name = "txtcid";
			this.txtcid.TabIndex = 3;
			this.txtcid.Text = "";
			this.txtcid.TextChanged += new System.EventHandler(this.txtcid_TextChanged);
			// 
			// txtname
			// 
			this.txtname.Location = new System.Drawing.Point(150, 168);
			this.txtname.Name = "txtname";
			this.txtname.Size = new System.Drawing.Size(192, 20);
			this.txtname.TabIndex = 4;
			this.txtname.Text = "";
			// 
			// txtdob
			// 
			this.txtdob.Location = new System.Drawing.Point(150, 252);
			this.txtdob.Name = "txtdob";
			this.txtdob.Size = new System.Drawing.Size(120, 20);
			this.txtdob.TabIndex = 6;
			this.txtdob.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(20, 24);
			this.label1.Name = "label1";
			this.label1.TabIndex = 4;
			this.label1.Text = "Student Id";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(20, 120);
			this.label2.Name = "label2";
			this.label2.TabIndex = 5;
			this.label2.Text = "Course Id";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(20, 165);
			this.label3.Name = "label3";
			this.label3.TabIndex = 6;
			this.label3.Text = "Student Name";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(20, 252);
			this.label4.Name = "label4";
			this.label4.TabIndex = 7;
			this.label4.Text = "Dob";
			// 
			// gpsex
			// 
			this.gpsex.Controls.AddRange(new System.Windows.Forms.Control[] {
																				this.radfemale,
																				this.radmale});
			this.gpsex.Location = new System.Drawing.Point(155, 335);
			this.gpsex.Name = "gpsex";
			this.gpsex.Size = new System.Drawing.Size(188, 52);
			this.gpsex.TabIndex = 8;
			this.gpsex.TabStop = false;
			// 
			// radfemale
			// 
			this.radfemale.Location = new System.Drawing.Point(16, 20);
			this.radfemale.Name = "radfemale";
			this.radfemale.Size = new System.Drawing.Size(64, 24);
			this.radfemale.TabIndex = 8;
			this.radfemale.Text = "Female";
			// 
			// radmale
			// 
			this.radmale.Location = new System.Drawing.Point(96, 20);
			this.radmale.Name = "radmale";
			this.radmale.Size = new System.Drawing.Size(68, 24);
			this.radmale.TabIndex = 9;
			this.radmale.Text = "Male";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(20, 296);
			this.label5.Name = "label5";
			this.label5.TabIndex = 9;
			this.label5.Text = "Father\'s Name";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(20, 350);
			this.label6.Name = "label6";
			this.label6.TabIndex = 10;
			this.label6.Text = "Sex";
			// 
			// txtfather
			// 
			this.txtfather.Location = new System.Drawing.Point(150, 296);
			this.txtfather.Name = "txtfather";
			this.txtfather.Size = new System.Drawing.Size(212, 20);
			this.txtfather.TabIndex = 7;
			this.txtfather.Text = "";
			// 
			// gppersonal
			// 
			this.gppersonal.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.txtphone,
																					 this.txtaddress,
																					 this.txtemail,
																					 this.txtqualification,
																					 this.label10,
																					 this.label9,
																					 this.label8,
																					 this.label7});
			this.gppersonal.Location = new System.Drawing.Point(412, 8);
			this.gppersonal.Name = "gppersonal";
			this.gppersonal.Size = new System.Drawing.Size(428, 222);
			this.gppersonal.TabIndex = 12;
			this.gppersonal.TabStop = false;
			this.gppersonal.Text = "PERSONAL DETAILS";
			// 
			// txtphone
			// 
			this.txtphone.Location = new System.Drawing.Point(130, 165);
			this.txtphone.Name = "txtphone";
			this.txtphone.Size = new System.Drawing.Size(148, 20);
			this.txtphone.TabIndex = 13;
			this.txtphone.Text = "";
			// 
			// txtaddress
			// 
			this.txtaddress.Location = new System.Drawing.Point(130, 115);
			this.txtaddress.Name = "txtaddress";
			this.txtaddress.Size = new System.Drawing.Size(288, 20);
			this.txtaddress.TabIndex = 12;
			this.txtaddress.Text = "";
			// 
			// txtemail
			// 
			this.txtemail.Location = new System.Drawing.Point(130, 70);
			this.txtemail.Name = "txtemail";
			this.txtemail.Size = new System.Drawing.Size(200, 20);
			this.txtemail.TabIndex = 11;
			this.txtemail.Text = "";
			// 
			// txtqualification
			// 
			this.txtqualification.Location = new System.Drawing.Point(132, 28);
			this.txtqualification.Name = "txtqualification";
			this.txtqualification.Size = new System.Drawing.Size(204, 20);
			this.txtqualification.TabIndex = 10;
			this.txtqualification.Text = "";
			this.txtqualification.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(10, 165);
			this.label10.Name = "label10";
			this.label10.TabIndex = 3;
			this.label10.Text = "Phone Number";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(12, 115);
			this.label9.Name = "label9";
			this.label9.TabIndex = 2;
			this.label9.Text = "Address";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(12, 70);
			this.label8.Name = "label8";
			this.label8.TabIndex = 1;
			this.label8.Text = "E-mail Id";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(12, 28);
			this.label7.Name = "label7";
			this.label7.TabIndex = 0;
			this.label7.Text = "Qualification";
			// 
			// btnsubmit
			// 
			this.btnsubmit.Location = new System.Drawing.Point(100, 445);
			this.btnsubmit.Name = "btnsubmit";
			this.btnsubmit.Size = new System.Drawing.Size(85, 30);
			this.btnsubmit.TabIndex = 14;
			this.btnsubmit.Text = "Submit";
			this.btnsubmit.Click += new System.EventHandler(this.btnsubmit_Click);
			// 
			// gpstudentdetails
			// 
			this.gpstudentdetails.Controls.AddRange(new System.Windows.Forms.Control[] {
																						   this.label13,
																						   this.label12,
																						   this.txtdoj,
																						   this.label11,
																						   this.comboBox1,
																						   this.lblcoursename,
																						   this.gpsex,
																						   this.label6,
																						   this.label5,
																						   this.txtfather,
																						   this.label4,
																						   this.txtdob,
																						   this.label3,
																						   this.txtname,
																						   this.label2,
																						   this.txtcid,
																						   this.label1});
			this.gpstudentdetails.Location = new System.Drawing.Point(16, 8);
			this.gpstudentdetails.Name = "gpstudentdetails";
			this.gpstudentdetails.Size = new System.Drawing.Size(384, 400);
			this.gpstudentdetails.TabIndex = 15;
			this.gpstudentdetails.TabStop = false;
			this.gpstudentdetails.Text = "STUDENT DETAILS";
			// 
			// label13
			// 
			this.label13.Location = new System.Drawing.Point(280, 256);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(80, 24);
			this.label13.TabIndex = 17;
			this.label13.Text = "mm/dd/yyyy";
			// 
			// label12
			// 
			this.label12.Location = new System.Drawing.Point(280, 216);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(80, 23);
			this.label12.TabIndex = 16;
			this.label12.Text = "mm/dd/yyyy";
			// 
			// txtdoj
			// 
			this.txtdoj.Location = new System.Drawing.Point(150, 216);
			this.txtdoj.Name = "txtdoj";
			this.txtdoj.Size = new System.Drawing.Size(120, 20);
			this.txtdoj.TabIndex = 5;
			this.txtdoj.Text = "";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(20, 205);
			this.label11.Name = "label11";
			this.label11.TabIndex = 14;
			this.label11.Text = "Date of Joining";
			// 
			// comboBox1
			// 
			this.comboBox1.Items.AddRange(new object[] {
														   "dotnet",
														   "java",
														   "bioinformatics",
														   "oracle",
														   "unix"});
			this.comboBox1.Location = new System.Drawing.Point(150, 80);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(121, 21);
			this.comboBox1.TabIndex = 2;
			this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
			// 
			// lblcoursename
			// 
			this.lblcoursename.Location = new System.Drawing.Point(20, 70);
			this.lblcoursename.Name = "lblcoursename";
			this.lblcoursename.TabIndex = 12;
			this.lblcoursename.Text = "Course Name";
			// 
			// btncancel
			// 
			this.btncancel.Location = new System.Drawing.Point(210, 445);
			this.btncancel.Name = "btncancel";
			this.btncancel.Size = new System.Drawing.Size(90, 30);
			this.btncancel.TabIndex = 15;
			this.btncancel.Text = "Close";
			this.btncancel.Click += new System.EventHandler(this.btncancel_Click);
			// 
			// REGISTRATIONFORM
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(804, 588);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btncancel,
																		  this.gppersonal,
																		  this.txtsid,
																		  this.btnsubmit,
																		  this.gpstudentdetails});
			this.Name = "REGISTRATIONFORM";
			this.Text = "reg";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.REGISTRATIONFORM_Load);
			this.gpsex.ResumeLayout(false);
			this.gppersonal.ResumeLayout(false);
			this.gpstudentdetails.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		SqlConnection con;
		DataTable dt,dt1;
		DataRow dr,dr1;
		SqlCommandBuilder scmd,scmd1;
		SqlDataAdapter da ,da1;
		DataSet ds,ds1;

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void btncancel_Click(object sender, System.EventArgs e)
		{
			this.Dispose();
		}

		

		private void REGISTRATIONFORM_Load(object sender, System.EventArgs e)
		{
			con=new SqlConnection("Server=COMPUTER3;Integrated Security=SSPI; initial catalog=STG");
			con.Open();

			

			da1=new SqlDataAdapter("Select * from student_details",con);
			ds1=new DataSet();
			
			
			da1.Fill(ds1,"student_details");
			dt1=ds1.Tables["student_details"];
	
			da =new SqlDataAdapter("Select * from PersonalDetails",con);
			ds=new DataSet();
		

			da.Fill(ds,"Personaldetails");
			dt=ds.Tables["Personaldetails"];	
		
		}

		private void btnsubmit_Click(object sender, System.EventArgs e)
		{
		
		con.Close();
			con.Open();
				dr1=dt1.NewRow();
				dr1["stu_id"]=txtsid.Text;

			    dr1["course_name"]=comboBox1.SelectedItem.ToString();
				dr1["course_id"]=txtcid.Text;
				dr1["student_name"]=txtname.Text;
				dr1["doj"]=txtdoj.Text;
				dr1["dob"]=txtdob.Text;
				if(radfemale.Checked==true)
				{
					dr1["sex"]="female";
				}
				else if(radmale.Checked==true)
				{
					dr1["sex"]="male";
				}
				dr1["father_name"]=txtfather.Text;
				dt1.Rows.Add(dr1);
				scmd1=new SqlCommandBuilder(da1);
				da1.Update(ds1,"student_details");


				dr=dt.NewRow();
				dr["stu_id"]=txtsid.Text;
				dr["ph_no"]=txtphone.Text;
				dr["address"]=txtaddress.Text;
				dr["qualification"]=txtqualification.Text;
				dr["email_id"]=txtemail.Text;

				dt.Rows.Add(dr);
				scmd=new SqlCommandBuilder(da);
				da.Update(ds,"PersonalDetails");
	


				MessageBox.Show("Form is submitted.....Enter Payment Details Next");
				paymentdetails obj=new paymentdetails(txtsid.Text);
				obj.Show();

			
			
		}

		private void txtsid_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void txtcoursename_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void txtcid_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		

		private void btnfind_Click(object sender, System.EventArgs e)
		{
			
		}

		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(comboBox1.SelectedItem.ToString()!="")
			{
				string c_name=comboBox1.SelectedItem.ToString();
				con.Close();
				con.Open();
				SqlCommand cmd=new SqlCommand("select course_id from courseinformation where course_name=@cname",con);
				cmd.Parameters.Add("@cname",c_name.ToLower());
				SqlDataReader dr=cmd.ExecuteReader();
				if(dr.Read())
				{
					txtcid.Text=dr.GetValue(0).ToString();
				}
				
			}
		}

	}
}
